<template>
	<view class="container">
		<!-- 用户信息 -->
		<view class="user_section">
			<image src="../../static/img/userCenter/user_bg.jpg" class="bg">
			</image>
			<!-- 信息 -->
			<view class="user_info_box">
				<!-- 登陆 -->
				<view class="login">
					<!-- 头像框 -->
					<view class="head_portrai_box">
						<image src="../../static/img/user_picture.jpg" mode=""></image>
					</view>
					<view class="login_button">
						立即登陆
					</view>
				</view>
				<!-- 会员 -->
				<view class="vip">
					<u-row class="vip_info">
						<u-col span="1">
							<u-icon name="level" color="#CD7F32" size="30px"></u-icon>
						</u-col>
						<u-col span="8">
							<text class="vip_level">普通会员</text>
						</u-col>
						<u-col span="3">
							<view class="open_vip">
								立即开通
							</view>
						</u-col>
					</u-row>
					<!-- 会员权限 -->
					<view class="vip_equity">
						<text>VIP权益</text>
						<view class="open">
							请联系管理员开通
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 功能部分 -->
		<view class="cover-container" :style="[{
				transform: coverTransform,
				transition: coverTransition
			}]" @touchstart="coverTouchstart" @touchmove="coverTouchmove" @touchend="coverTouchend">
			<image class="arc" src="../../static/img/userCenter/arc.png"></image>
			<view class="option_section">
				<!-- 资产 -->
				<u-row class="assets_box">
					<u-col span="4" textAlign="center">
						<view class="assets_num">1000</view>
						<text>原力</text>
					</u-col>
					<u-col span="4" textAlign="center">
						<view class="assets_num">1000</view>
						<text>火石</text>
					</u-col>
					<u-col span="4" textAlign="center">
						<view class="assets_num">1000</view>
						<text>火源</text>
					</u-col>
				</u-row>
				<!-- 功能 -->
				<u-row class="function_box">
					<u-col span="3" textAlign="center">
						<view>
							<image src="../../static/img/userCenter/order.svg"></image>
						</view>
						<text>全部订单</text>
					</u-col>
					<u-col span="3" textAlign="center">
						<view>
							<image src="../../static/img/userCenter/pay.svg"></image>
						</view>
						<text>待付款</text>
					</u-col>
					<u-col span="3" textAlign="center">
						<view>
							<image src="../../static/img/userCenter/goodsing.svg"></image>
						</view>
						<text>待收货</text>
					</u-col>
					<u-col span="3" textAlign="center">
						<view>
							<image src="../../static/img/userCenter/after-sales.svg"></image>
						</view>
						<text>退款/售后</text>
					</u-col>
				</u-row>
				<!-- 设置 -->
				<view class="set_box">
					<list-cell v-for="(item, index) in 5" :key="index" listName="我的消费"></list-cell>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	let startY = 0,
		moveY = 0,
		pageAtTop = true;
	export default {
		data() {
			return {
				coverTransform: 'translateY(0px)',
				coverTransition: '0s',
				moving: false,
				footprintList: [],
				isVip: false,
			};
		},
		methods: {
			coverTouchstart(e) {
				if (pageAtTop === false) {
					return;
				}
				this.coverTransition = 'transform .1s linear';
				startY = e.touches[0].clientY;
			},
			coverTouchmove(e) {
				moveY = e.touches[0].clientY;
				let moveDistance = moveY - startY;
				if (moveDistance < 0) {
					this.moving = false;
					return;
				}
				this.moving = true;
				if (moveDistance >= 80 && moveDistance < 100) {
					moveDistance = 80;
				}

				if (moveDistance > 0 && moveDistance <= 80) {
					this.coverTransform = `translateY(${moveDistance}px)`;
				}
			},
			coverTouchend() {
				if (this.moving === false) {
					return;
				}
				this.moving = false;
				this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
				this.coverTransform = 'translateY(0px)';
			}
		}
	}
</script>

<style lang="scss">
	.user_section {
		height: 600rpx;
		position: relative;

		.bg {
			width: 100%;
			height: 100%;
		}

		.user_info_box {
			position: absolute;
			top: 60rpx;
			width: 100%;
			height: 300rpx;

			.login {
				padding: 30rpx;
				display: flex;
				align-items: center;

				.head_portrai_box {
					width: 140rpx;
					height: 140rpx;
					border-radius: 50%;
					margin-right: 40rpx;
					font-size: 40rpx;
					border: 2px solid white;
					overflow: hidden;
					
					image{
						width: 100%;
						height: 100%;
					}
				}

				.login_button {
					color: white;
					font-size: 36rpx;
					font-weight: bold;
				}
			}

			.vip {
				margin: 0 30rpx;
				padding: 30rpx 30rpx;
				background-image: linear-gradient(to left, rgba(0, 0, 0, .7), rgba(0, 0, 0, .8));
				border-radius: 16upx 16upx 0 0;

				.vip_info {
					margin-bottom: 40rpx;

					.vip_level {
						margin-left: 20rpx;
						color: #CD7F32;
						font-size: 30rpx;
					}
					
					.open_vip{
						background-image: linear-gradient(to left, #f9e6af, #ffd465);
						text-align: center;
						border-radius: 20rpx;
						width: 140rpx;
					}
				}

				.vip_equity {

					text {
						color: #CD7F32;
						font-size: 30rpx;
					}

					.open {
						color: #777;
						font-size: $bsin-basin-font;
						margin-top: 16rpx;
						margin-bottom: 40rpx;
					}
				}
			}

		}
	}

	.cover-container {
		position: relative;
		z-index: 2;
		top: -280rpx;
		margin-bottom: -280rpx;

		.arc {
			width: 100%;
			height: 100rpx;
		}

		.option_section {
			background-color: #F9F9F9;
			position: relative;
			top: -20rpx;

			.assets_box {
				padding: 20rpx;
				margin: 0 30rpx;
				background-color: #FFFFFF;

				.assets_num {
					font-size: $bsin-basin-font;
				}

				text {
					margin-top: 10rpx;
					color: #777;
				}
			}

			.function_box {
				padding: 40rpx;
				margin: 30rpx;
				background-color: #FFFFFF;

				image {
					width: 48rpx;
					height: 48rpx;
				}
			}

			.set_box {
				margin: 30rpx;
				background-color: #FFFFFF;
				font-size: $bsin-basin-font;
			}
		}
	}
</style>
